package application;

import javax.swing.SwingUtilities;

import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;

import javafx.application.Application;
import javafx.embed.swing.SwingNode;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main2 extends Application {

	@Override
	public void start(Stage stage) throws Exception {

		StackPane root = new StackPane();
		Scene scene = new Scene(root, 500, 600);

		mxGraph graph = new mxGraph();
		Object parent = graph.getDefaultParent();

		graph.getModel().beginUpdate();
		try {
			Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80, 30, "shape=cloud;fillColor=#fff");
			Object v2 = graph.insertVertex(parent, null, "World!", 240, 150, 80, 30);
			graph.insertEdge(parent, null, "Edge", v1, v2);
		} finally {
			graph.getModel().endUpdate();
		}

		mxGraphComponent graphComponent = new mxGraphComponent(graph);

		SwingNode node = new SwingNode();

		SwingUtilities.invokeLater(() -> {
			node.setContent(graphComponent);
		});

		root.getChildren().addAll(node);

		stage.setScene(scene);
		stage.setTitle("JavaFx And JGraphx");
		stage.show();

	}

	public static void main(String[] args) {
		launch(args);
	}

}
